ShowTable of Contents
This article will go through the steps required to set up a provided test project to test your custom XPages controls.
In this tutorial we will be using an example control project: com.example.greenbox
, but same steps can be applied to other controls.
To follow this tutorial, import the com.example.greenbox
project which can be found in the article's Attachments
Configuring Test Project
In the MANIFEST.MF
in the test project, remove dependency on the com.example.xsp
Add a new dependency for your control (in our case it's com.example.greenbox
) so it looks like so:
In the project open WEB-INF/xsp.properties
Change the dependency from com.example.library
to your own (in our case it's com.example.greenbox.library
It should look like so:
in the test project package com.ibm.xsp.test.framework
Change the target
to your own control
(in our case it's com.example.greenbox.library
respectively). It should look like so:
# The XspLibrary.getLibraryId() value of the library
# whose contents should be tested, defaults to none,
# meaning that only local xsp-configs are loaded.
# Package name and component-type prefix, like "com.ibm.xsp" or
# "com.ibm.xsp.extlib", used in the NamingConventionTest
# Extra libraries whose xsp-config files should be loaded
# when creating a registry
In the test project, open pages/simpleTestOfExampleControl.xsp
Change the XPage(prefix, namespace, tag) to use your own control. In our case it should look like so:
Delete the contents of the gen
folder in the test project.
Re-run the tests. Refresh the test project. gen
folder should now contain generated Java Classes for the corresponding XPage above.
Before we continue to the next section, we need to fix a compile error in the ExamplePrintTagNamesAndProps
In the test project, open ExamplePrintTagNamesAndProps.java
from the xsp.example.test.version
Somewhere around line #22 change the following code to use your own control (in our case it's Greenbox Library).
tagsAndProps = filterToDependsLibrary(registry, (new ExampleLibrary()).getLibraryId(), tagsAndProps);
tagsAndProps = filterToDependsLibrary(registry, (new GreenboxLibrary()).getLibraryId(), tagsAndProps);
You might need to organize your imports (Ctrl+Shift+O) to remove unused references to the old control.
Renaming Test Project
The sample test project was named to use with the example control. In this section we will go through the steps to rename the test project to use with our control.
For the tutorial purpose, we will be renaming the project to our Greenbox example control but same steps can applied to your own control.
We will start with renaming the project name and proceed to packages after.
Right click on the com.example.junit.tests
project. Refactor -> Rename